package com.ctrip.framework.apollo;

import com.alipay.sofa.sofamq.client.PropertyKeyConst;
import io.openmessaging.api.*;

import java.util.Properties;

/**
 * $NAME
 *
 * @author wangrui
 * @since 2025/9/28 10:35
 * <br/>
 * # 运行模式 run.mode=NORMAL
 * # 环境标识 com.alipay.env=shared
 * # 实例标识 com.alipay.instanceid=Z4TBSOSOG2VD
 * # AntVIP 地址 com.antcloud.antvip.endpoint=cn-hangzhou-middleware-acvip-prod.cloud.alipaycs.net
 * # 访问控制键 ID com.antcloud.mw.access= $ {AK}
 * # 访问控制密钥密钥 com.antcloud.mw.secret=$ {SK}
 * AK: LTAI5tG1NtaXGfzKhdd8FK7D
 * SK: XIDDsIwYItciHdD63dL2UxIU3gm0ZA
 */
public class AsyncProducer {
    public static void main(String[] args) throws Exception {

        Properties properties = new Properties();
        properties.setProperty(PropertyKeyConst.GROUP_ID, "GID_comstar_test");
        Producer producer = AccessPoint.getAccessPoint().createProducer(properties);

        producer.start();

        String msgBody = "Message Body";
        Message message = new Message(MqConfig.TOPIC,MqConfig.TAG, msgBody.getBytes());
       producer.sendAsync(message, new SendCallback() {
            @Override
            public void onSuccess(SendResult sendResult) {
                System.out.println("send success, SendResult:" + sendResult);
            }

            @Override
            public void onException(OnExceptionContext onExceptionContext) {
                System.err.println("send exception, onExceptionContext:" + onExceptionContext);
            }
        });


    }
}